<?php

class Shop_Widgets_Searchform_Widget extends Tomato_Widget
{
    protected function _prepareShow()
    {	
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $params = $request->getParam('q');
        if (null != $params && $request->getParam('action') == 'search') {
            $exp = rawurldecode(base64_decode($params));
            $exp = Zend_Json::decode($exp);
            $this->_view->assign('w_exp', $exp);
        }

        $lang = $request->getParam('lang');

        /**
        * Get connection to database
        **/
        $conn = Tomato_Db_Connection::factory()->getMasterConnection();

        /**
         * Category models access to data
         */
        $categoryDao = Tomato_Model_Dao_Factory::getInstance()->setModule('shop')->getCategoryDao();
        $categoryDao->setDbConnection($conn);
        $categoryDao->setLang($lang);

        /**
        * Get category for selectbox
        **/
        $objCategories = $categoryDao->getFTree();
        $this->_view->assign('objCategories', $objCategories);
    }
    protected function _prepareConfig()
    {

    }
}
